<?php

/**
 * Description of ApiService
 *
 * @author gun
 */

class Admin_Model_ResourceService extends Admin_Model_BaseService {
    protected $daoClass = 'Admin_Model_DbTable_Resource'; 
    
    public function getAll($where = array(), $options = array()) {
        $data = $this->getDao()->getAll($where, $options);        
        $category = $this->getCategory();                
        
        foreach ($data as $key => $value) {
            foreach ($category as $k => $v) {
                if ($v['catID'] === $value['category'])
                    $data[ $key ]['category'] =  $v['name'];
            }
        }
        
        return $data;
    }
    
    public function getRow($id = '') {
        $data = $this->getDao()->getRow($id);
        
        return $data;
    }
    
    public function countRows($where = '') {
        return $this->getDao()->countRows($where);
    }
    
    public function checkMeta($where = '') {
        return $this->getDao()->checkMeta($where);
    }
    
    public function doUpdate($data = array(), $where = '') {
        return $this->getDao()->doUpdate($data, $where);
    }
    
    public function doSave($data = array()) {
        return $this->getDao()->doSave($data);
    }
    
    public function updateMeta($meta = array(), $where = '') {
        return $this->getDao()->updateMeta($meta, $where);
    }
    
    public function saveMeta($meta = array()) {
        return $this->getDao()->saveMeta($meta);
    }
    
    public function doDelete($where = '') {
        return $this->getDao()->doDelete($where);
    }

    public function getCategory() {
        return $this->getDao()->getCategory();
    }
}
